package net.oschina.simpleplus.gen;

import org.apache.commons.lang3.StringUtils;

public class ProtoFieldBean extends ProtoField {

	public ProtoFieldBean() {
		super();
	}

	public ProtoFieldBean(String name, String javaType) {
		super(name, javaType);
	}

	@Override
	public StringBuffer appendBuildMethod(StringBuffer buffer) {
		return buffer.append("\n\t\t")
				.append("builder.set")
				.append(StringUtils.capitalize(name))
				.append("(")
				.append(name)
				.append(".build());");
	}

	@Override
	public StringBuffer appendCopyFromMethod(StringBuffer buffer) {
		return buffer.append("\n\t\t")
				.append("this.")
				.append(name)
				.append(".copyFrom(t.get")
				.append(StringUtils.capitalize(name))
				.append("());");
	}

	@Override
	protected String defaultInitlized() {
		return new StringBuffer().append("new ").append(javaType).append("()").toString();
	}

}
